package com.fsj.miniapp.caches;

import org.springframework.util.CollectionUtils;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class UserCache {

    static final Map<Long, Set<String>> funcsCache = new ConcurrentHashMap<>();

    public static Set<String> getFuncsByUserId(Long id) {
        return funcsCache.get(id);
    }

    public static void setFuncs(Long id, Set<String> funcs) {
        Set<String> strings = funcsCache.get(id);
        if (!CollectionUtils.isEmpty(strings)) {
            strings.addAll(funcs);
            funcsCache.put(id, strings);
            return;
        }
        funcsCache.put(id, funcs);
    }
}
